<template>
  <!-- html -->
  <div class="person">
    <h1>有个人叫{{ person.name }},现在{{ person.age }}岁</h1>
    <button @click="changeAge">修改年龄</button>
    <button @click="changePerson">换人</button>
  </div>
</template>

<script lang="ts" setup name="Person">
import { reactive, ref } from "vue";

let person = reactive({ name: "xiaoji", age: 18 });

function changeAge() {
  person.age += 1;
}

function changePerson() {
  //person = ({ name: "xiaoqin", age: 27 })  不行
  // person = relative({ name: "xiaoqin", age: 27 });  不行
  Object.assign(person, { name: "xiaoqin", age: 27 });
  // person.value = { name: "xiaoqin", age: 27 };  //只要动了.value属性 必会响应
}
</script>

<style scoped>
/* 样式 */
.person {
  background-color: skyblue;
  box-shadow: 0 0 10px;
  border-radius: 10px;
  padding: 20px;
}
button {
  margin: 0 5px;
}
</style>
